<template>
  <div class="company-home">
    <div class="company-title">{{ store.users.name }}</div>

    <div class="banner-wrapper">
      <a-carousel autoplay v-if="store.user_index_top">
        <div v-for="item in store.user_index_top" :key="item.pic">
          <img :src="item.pic" />
        </div>
      </a-carousel>
    </div>

    <div class="content-wrapper">
      <div v-html="store.content"></div>
    </div>

    <div class="goods-wrapper" v-if="goodsList.length">
      <div class="goods-title">主打商品或服务</div>
      <div class="goods-list">
        <div
          class="goods-item"
          v-for="item in goodsList.slice(0, 5)"
          :key="item.ID"
          @click="go(item)"
        >
          <img :src="item.pic[0].pic" class="pic" />

          <div class="title-wrapper">
            <div class="title">
              {{ item.title }}
            </div>

            <div class="desc-wrapper">
              <span>{{ item.c_product_info.name }}</span>
              <span>{{ item.c_work_info.name }}</span>
            </div>
          </div>
        </div>

        <img
          src="./images/more.png"
          class="more"
          @click="
            $router.push({
              path: $route.path + '/goods'
            })
          "
        />
      </div>
    </div>
  </div>
</template>

<script>
import storage from "@/utils/storage";
export default {
  props: {
    store: {
      type: Object,
      default: () => {}
    },
    goodsList: {
      type: Array,
      default: () => []
    }
  },
  methods: {
    go(item) {
      storage.setItem("GOODS_ITEM", item);
      this.$router.push({
        path: this.$route.path + "/goods/" + item.ID
      });
    }
  }
};
</script>

<style lang="less" scoped>
.company-home {
  background: @white;

  .company-title {
    text-align: center;
    font-size: 24px;
    font-weight: bold;
    padding: 20px;
  }

  .banner-wrapper {
    margin: auto;
    text-align: center;

    img {
      width: 100%;
      height: 500px;
      object-fit: cover;
    }
  }

  /deep/.content-wrapper {
    padding: 20px 0 30px;
    border-bottom: 1px solid @border-color;
    img {
      width: 100%;
    }

    p {
      padding: 0 50px;
    }
  }

  .goods-wrapper {
    padding: 20px 60px 0;
    overflow: hidden;

    .goods-title {
      font-size: 18px;
      font-weight: bold;
      text-align: center;
    }

    .goods-list {
      margin-top: 20px;
      display: flex;
      align-items: center;

      .more {
        width: 28px;
        position: relative;
        cursor: pointer;
        top: -30px;
      }

      .goods-item {
        width: 180px;
        border: 1px solid @border-color;
        border-radius: 4px;
        overflow: hidden;
        margin-bottom: 24px;
        cursor: pointer;
        text-align: left;
        float: left;
        margin-right: 40px;
        .pic {
          width: 180px;
          height: 180px;
          object-fit: cover;
        }

        .title-wrapper {
          padding: 12px;
        }

        .title {
          font-size: 17px;
        }

        .desc-wrapper {
          color: @text-color-2;
          margin-top: 4px;

          span {
            margin-right: 12px;
          }
        }
      }
    }
  }
}
</style>
